/* Yet Another Experimental Software Renderer
 *
 * Copyright (c) 2010 Pawel "Hery" Dziepak
 */

#ifndef TEXTURE_H_
#define TEXTURE_H_

#include "vectors.h"

#include <string>

namespace yaesr {
	class texture {
	public:
		texture(int w, int h) : width(w), height(h) { }

		virtual color get_pixel(int x, int y) const = 0;

		virtual void put_pixel(int x, int y, color clr) = 0;

		int get_width() const {
			return width;
		}

		int get_height() const {
			return height;
		}

	protected:
		const int width, height;

	private:
		texture &operator=(texture &){}
	};

	class color_texture : public texture {
	public:
		static color_texture *load_bmp(const std::string &fname);
		static color_texture *create(int width, int height);

		color get_pixel(int x, int y) const;
		void put_pixel(int x, int y, color clr);

	private:
		color_texture(int w, int h) : texture(w, h) {}

		u32 *data;
	};

	class depth_texture : public texture {
	public:
		static depth_texture *create(int width, int height);

		color get_pixel(int x, int y) const;
		void put_pixel(int x, int y, color value);

	private:
		depth_texture(int width, int height) : texture(width, height) {}

		double *data;
	};
}

#endif